
console.log("-".repeat(10) + "例1" + "-".repeat(10));
const obj1 = {
  age: 18,
  name: 'zg'
}

const obj2 = Object.assign({ grade: 'A', friends: ['lucy'] }, obj1);
console.log(obj1);
/*
  {
    "age": 18,
    "name": "zg"
  } 
*/
console.log(obj2);
/*
  {
    "grade": "A",
    "friends": [
        "lucy"
    ],
    "age": 18,
    "name": "zg"
  }
*/

console.log("-".repeat(10) + "例2" + "-".repeat(10));
const obj3 = {
  name: 'jam',
  age: 23,
  friends: ['lucy'],
  height: "1.88m"
}
const obj4 = {
  name: 'zg',
  age: 22,
  grade: 'A'
}
Object.assign(obj3, obj4);
console.log(obj3);
/*
  {
    "name": "zg",
    "age": 22,
    "friends": [
        "lucy"
    ],
    "height": "1.88m",
    "grade": "A"
  }
*/
console.log(obj4);
/*
  {
    "name": "zg",
    "age": 22,
    "grade": "A"
  }
*/

console.log("-".repeat(10) + "例3" + "-".repeat(10));
const obj5 = {
  a: 1
};
const obj6 = {
  b: 2
};
const obj7 = {
  c: 3
};
const obj8 = Object.assign(obj5, obj6, obj7);
console.log(obj5);
/*
  {
    "a": 1,
    "b": 2,
    "c": 3
  }
*/
console.log(obj6);
/*
  {
    "b": 2
  }
*/
console.log(obj7);
/*
  {
    "c": 3
  }
*/
console.log(obj8);
/*
  {
    "a": 1,
    "b": 2,
    "c": 3
  }
*/
